package 面向对象中级;

public class StringBufferTest {

    //StringBuffer没用
    //jdk8开始，编译器优化  17
    //String str="aaa";                 StringBuffer sb=new StringBuffer("aaa");
    // str+="bbb";      编译   ======》  sb.append("bbb");
    public static void main(String[] args) {
        //1.创建StringBuffer对象
        StringBuffer sb=new StringBuffer();
        //ctrl+b "abcd" ['a','b','c','d']byte[] value;
        //2.增
        sb.append("abc");//abc
        sb.append(123);//abc123
        //3.删
        sb.delete(2,4);//ab23 [2,4)
        //4.改
        sb.insert(1,"哈哈");//a哈哈b23
        sb.replace(1,3,"*");//  [1,3) a*b23
        //sb.substring()
        //5.其他
        sb.reverse();//反转数组  3 2 b * a
        //6.查
        String str=sb.toString();//byte[]==>String
        System.out.println(str);
    }
}
